using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using Pervote.Core;
using Pervote.Core.Logic;

public partial class PollMain : RegularPageBase
{
    private Poll poll;
    public Poll Poll
    {
        get { return poll; }
        set { poll = value; }
    }

    new protected void Page_Load(object sender, EventArgs e)
    {
        long pollId = 0;
        try
        {
            pollId = long.Parse(Request.QueryString["id"]);
        }
        catch
        {
            string redirectUrl = (Request.UrlReferrer != null) ? Request.UrlReferrer.AbsoluteUri : "/";
            Response.Redirect(redirectUrl);
        }

        PollManager pollManager = new PollManager();
        ErrorInfo error = new ErrorInfo();
        MembershipUser user = Membership.GetUser();
        string userName = (user != null) ? user.UserName : null;
        Poll poll = pollManager.GetPollView(pollId, userName, error);
        if (poll != null) PollView.LoadPoll(poll);
    }

    protected string GetLogoCssClass(string fqCatName)
    {
        return "catLogo-Music";
        //return "catLogo-" + fqCatName.Substring(0, fqCatName.IndexOf('/') != -1 ? fqCatName.IndexOf('/') : fqCatName.Length);
    }
}
